package com.amigo.online.provider.compare.quartzjob.random;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import com.amigo.online.provider.common.ConstantValue;
import com.amigo.online.provider.common.entity.VideoMongoInfo;
import com.amigo.online.provider.common.entity.VideoMysqlInfo;
import com.amigo.online.provider.common.entity.VideoSolrInfo;
import com.amigo.online.provider.compare.quartzjob.AbstractCompareJob;
import com.amigo.online.provider.compare.quartzjob.AbstractVideoComparisonJob;
import com.amigo.online.provider.compare.service.VideoComparisonService;
import com.amigo.online.provider.sync.handle.data.mongo.service.VideoMongoService;
import com.amigo.online.provider.sync.handle.data.solr.service.VideoSolrService;

/**
 * @version: V 1.0.0
 * @Description: （video 信息定时局部比对）
 * @author: zxy  QQ:1363320658
 * @date: 2018年12月10日 下午6:12:31
 */
public class VideoInfoRandomComparisonJob extends AbstractVideoComparisonJob implements Job {

    @Autowired
    VideoComparisonService videoComparisonService;

    @Autowired
    VideoSolrService videoSolrService;

    @Autowired
    VideoMongoService videoMongoService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        List<VideoMysqlInfo> videoMysqlList = videoComparisonService.listVideoInfoWithNumber(ConstantValue.RANDOM_COMPARSION_NUMBER);
        List<Long> ids = videoMysqlList.stream().map(obj -> obj.getId()).collect(Collectors.toList());
        List<VideoSolrInfo> videoSolrList = videoSolrService.listFindbyIds(ids);
        List<VideoMongoInfo> videoMongoList = videoMongoService.listVideoMongoInfoByIds(ids);
        compareVideo(videoMongoList, videoSolrList, videoMysqlList);
    }

}
